package core;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: lahiru
 * Date: 3/26/14
 * Time: 1:08 PM
 * To change this template use File | Settings | File Templates.
 */
public class Phone implements Serializable {
    private double vector[];  //TODO number of hidden units is 2048
    private int count;
    private int id;

    public Phone(String[] firstVector, int count, int id) {
        double doubleArray[] = new double[firstVector.length];
        int i = 0;
        for (String str : firstVector) {
            doubleArray[i] = Double.parseDouble(str.trim());
            i++;
        }
        this.vector = doubleArray;
        this.count = count;
        this.id = id;
    }

    public int getCount() {
        return count;
    }

//    public void incrementCount() {
//        this.count = count + 1;
//    }

    public int getId() {
        return id;
    }

    public void addActivations(String[] newVector) throws NumberFormatException {
        if (newVector.length != vector.length) {
            throw new NumberFormatException();
        }
        for (int i = 0; i < vector.length; i++) {
            vector[i] = vector[i] + Double.parseDouble(newVector[i].trim());
        }
        count = count + 1;
    }

    public void averageVector() {
        for (int i = 0; i < vector.length; i++) {
            vector[i] = vector[i] / count;
        }
    }


    public double[] getVector() {
        return vector;
    }
}
